package com.carstop.model;

import javax.servlet.*;
import javax.servlet.http.*;
import org.json.JSONArray;
import org.json.JSONException;

import com.carorderdetail.model.CarOrderDetailDAO;
import com.carorderdetail.model.CarOrderDetailJsonHandler;
import com.carorderdetail.model.CarOrderDetailVO;
import com.member.model.MemberJsonHandler;
import com.member.model.MemberVO;
import com.rider.model.CarRiderPathDAO;
import com.rider.model.CarRiderPathJsonHandler;
import com.rider.model.CarRiderPathVO;

import java.io.*;
import java.util.List;

public class CarStopServletAndroid extends HttpServlet {
    public void doGet(HttpServletRequest rq, HttpServletResponse rp) 
    				throws ServletException, IOException{
    	CarStopDAO carstopdao = new CarStopDAO();
    	CarStopDetailDAO  carstopdetailDAO =new CarStopDetailDAO();



		String driver_path_id = rq.getParameter("driver_path_id");

		String CarStopJsonStr="";
		if (driver_path_id==null){
			driver_path_id="";				
			
		}
	
		List<CarStopDetailVO> carstopdetaillist= carstopdetailDAO.findstop(driver_path_id);
		

		
		List<CarStopVO>  carstoplist= carstopdao.findposition(carstopdetaillist);
		CarStopJsonHandler carstopJsonHandler =new CarStopJsonHandler();
		CarStopJsonStr=carstopJsonHandler.toJSONArray(carstoplist).toString();
	       rp.setContentType("text/html; charset=utf-8");
	        PrintWriter out = rp.getWriter();
	        out.println(CarStopJsonStr); 
	        out.close();

  
    }
    
    public void doPost(HttpServletRequest rq, HttpServletResponse rp) 
    				throws ServletException, IOException{
    	CarStopDAO carstopdao = new CarStopDAO();
    	CarStopDetailDAO  carstopdetailDAO =new CarStopDetailDAO();



		String driver_path_id = rq.getParameter("driver_path_id");

		String CarStopJsonStr="";
		if (driver_path_id==null){
			driver_path_id="";				
			
		}
	
		List<CarStopDetailVO> carstopdetaillist= carstopdetailDAO.findstop(driver_path_id);
		

		
		List<CarStopVO>  carstoplist= carstopdao.findposition(carstopdetaillist);
		CarStopJsonHandler carstopJsonHandler =new CarStopJsonHandler();
		CarStopJsonStr=carstopJsonHandler.toJSONArray(carstoplist).toString();
	       rp.setContentType("text/html; charset=utf-8");
	        PrintWriter out = rp.getWriter();
	        out.println(CarStopJsonStr); 
	        out.close();
    }
    	
}